package com.five.community.service.impl;


import com.five.community.bean.Chargeproject;
import com.five.community.bean.Person;
import com.five.community.bean.vo.ChargedetailsmanagementVo;
import com.five.community.bean.vo.ChargeprojectVo;
import com.five.community.bean.vo.RepairVo;
import com.five.community.mapper.ChargeprojectMapper;
import com.five.community.service.ChargeprojectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChargeprojectServiceImpl implements ChargeprojectService {
    @Autowired
    private ChargeprojectMapper chargeprojectMapper;

    @Override
    public  List<Chargeproject> selectAllChargeproject() throws Exception{
        return chargeprojectMapper.selectAllChargeproject();
    }

    @Override
    public List<ChargeprojectVo> selectAll() throws Exception {
        return chargeprojectMapper.queryAll();
    }

    @Override
    public void insert(Chargeproject chargeproject) throws Exception {
        chargeprojectMapper.InsertChargeproject(chargeproject);
    }

    @Override
    public void deleteById(int id) throws Exception {
        chargeprojectMapper.DeleteChargeprojectVoById(id);
    }

    @Override
    public void update(Chargeproject chargeproject) throws Exception{
        chargeprojectMapper.UpdateChargeproject(chargeproject);
    }

    @Override
    public Chargeproject selectById(int id) throws Exception {
        return chargeprojectMapper.selectById(id);
    }

    @Override
    public List<ChargeprojectVo> selectByName(String name) throws Exception {
        return chargeprojectMapper.selectbyname(name);
    }
    @Override
    public PageInfo<ChargeprojectVo> getPageInfo(Integer pageNum, int pageSize) throws Exception {
        //先初始化模型在查询信息顺序不能颠倒
        //初始化分页插件模型
        PageHelper.startPage(pageNum,pageSize);
        //查询所有信息获得列表集合
        List<ChargeprojectVo> chargeprojectVos = chargeprojectMapper.queryAll();
        //分页模型加入数据
        PageInfo<ChargeprojectVo> pageInfo = new PageInfo<>(chargeprojectVos);
        //返回分页模型
        return pageInfo;
    }
}
